<template>
    <view v-if="h5LoginScopeBase">
        <div>
            <span>
                登录中···
            </span>
        </div>
    </view>
    <view v-else class="bg-white   min-h-full flex flex-col items-center px-[40rpx] pt-[120rpx] box-border flex-1">
        <view class=" ">
            <image class="w-[160rpx] h-[160rpx] rounded-full  " :src="appStore.getWebsiteConfig.logo" mode="widthFix" />
        </view>
        <view class="w-full mt-[140rpx] pb-[60rpx] ">

            <!-- 账号登录 -->
            <account-vue
                v-if="appStore.currentLoginWay === LoginWayEnum.ACCOUNT && appStore.getLoginConfig.loginWay.includes(LoginWayEnum.ACCOUNT)"></account-vue>
            <!-- 手机号登录 -->
            <sms-vue
                v-else-if="appStore.currentLoginWay === LoginWayEnum.SMS && appStore.getLoginConfig.loginWay.includes(LoginWayEnum.SMS)"></sms-vue>
        </view>
        <view class="w-full mt-[40rpx]" v-if="appStore.getLoginConfig.openOtherAuth === 1">
            <divider-text class="text-center" content="第三方登录"></divider-text>
            <view class="flex justify-around items-center mt-[40rpx]">
                <uni-icons type="weixin" color="#1fd76d" size="50" @click="handleLogin" />
            </view>
        </view>
        <modal-agreement-vue ref="modalAgreementRef" @confirm="handleModalConfirm"></modal-agreement-vue>
    </view>

    <view>
        <!-- <view v-if="appStore.currentLoginWay === LoginWayEnum.DEFAULT">
                <button class="bg-primary text-white mt-[60rpx]" @click="wxLogin"
                    v-if="appStore.getLoginConfig.openOtherAuth === 1"><text class="text-base">一键登录</text></button>
                <button class="bg-white border-2 bor mt-[40rpx]" @click="handleAccountLogin"><text
                        class="text-base">账号登录</text></button>
                <privacy-vue class="mt-[40rpx]" v-if="isOpenAgreement" v-model:is-read="isReadAgreement"></privacy-vue>
            </view> -->
    </view>

</template>
<script lang="ts" setup>
import { LoginWayEnum, WxOauthScopeEnum } from "@/enums/appEnums"
import { useAppStore } from "@/store/modules/app"
import AccountVue from "./account.vue"
import SmsVue from "./sms.vue"
import modalAgreementVue from "./modalAgreement.vue"
import { useLogin } from "./useLogin"
import DividerText from "@/components/divider/text.vue"
import { isWeixinClient } from "@/utils/client"
const modalAgreementRef = ref<InstanceType<typeof modalAgreementVue>>()
const appStore = useAppStore()
const isReadAgreement = ref(false)
const { wxOaLogin, login } = useLogin({})
const h5LoginScopeBase = ref(true)
// watch(() => appStore.getLoginConfig.wxOauthScope, (val) => {
//     if (appStore.getLoginConfig.wxOauthScope === WxOauthScopeEnum.BASE) {
//         h5LoginScopeBase.value = true
//     } else {
//         h5LoginScopeBase.value = false
//     }
// })
watchEffect(() => {
    if (appStore.getLoginConfig.wxOauthScope === WxOauthScopeEnum.BASE) {
        h5LoginScopeBase.value = true
    } else {
        h5LoginScopeBase.value = false
    }
})
// 登录
function handleLogin() {
    login(LoginWayEnum.WX_OA)
}
// 确认隐私条款
function handleModalConfirm() {
    isReadAgreement.value = true
}


onLoad(async () => {
  wxOaLogin()
    
}) 
</script>
<style lang="scss" scoped></style>